home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / MPW Related / MPW Interfaces / CIncludes / generic.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-17  |  2.6 KB  |  84 lines  |  [TEXT/MPS ]

  1. /*ident    "@(#)C++env:incl-master/proto-headers/generic.h    1.1" */
  2. #ifndef applec
  3. #usedby all
  4. #endif
  5. /**************************************************************************
  6.             Copyright (c) 1984 AT&T
  7.                 All Rights Reserved      
  8.  
  9.     THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
  10.     
  11.     The copyright notice above does not evidence any       
  12.     actual or intended publication of such source code.
  13.  
  14. *****************************************************************************/
  15.  
  16. #ifndef __GENERIC__
  17.  
  18. #define __GENERIC__ 1
  19.  
  20. /* macros to paste tokens together to form new names */
  21. /* 4.2BSD and System V cpp's have different mechanisms for
  22.    pasting tokens together, but 4.3BSD agrees with System V.
  23.    ANSI C has defined a new way.
  24. */
  25.  
  26. #ifdef applec // for Macintosh
  27. /* ANSI C preprocessors will not expand the arguments to a macro;
  28.  * so we need to add a level of indirection to allow macro expansion of
  29.  * arguments.  (Reiser preprocessors allowed the first arg to be expanded;
  30.  * this method will allow both to be expanded, which is better than none.)
  31.  */
  32. #define name2(a,b)      _name2_aux(a,b)
  33. #define _name2_aux(a,b)      a##b
  34. #define name3(a,b,c)    _name3_aux(a,b,c)
  35. #define _name3_aux(a,b,c)    a##b##c
  36. #define name4(a,b,c,d)  _name4_aux(a,b,c,d)
  37. #define _name4_aux(a,b,c,d)  a##b##c##d
  38.  
  39. #else 
  40.  
  41. #os bsd3 svr2 svr3 sunos3 sunos4 hpux uts
  42. #define name2(a,b)    a/**/b
  43. #define name3(a,b,c)    a/**/b/**/c
  44. #define name4(a,b,c,d)    a/**/b/**/c/**/d
  45. #endos
  46. #os bsd2 alliant
  47. #define name2(a,b) a\
  48. b
  49. #define name3(a,b,c) a\
  50. b\
  51. c
  52. #define name4(a,b,c,d) a\
  53. b\
  54. c\
  55. d
  56. #endos
  57.  
  58. #endif
  59.  
  60. #ifdef applec /* for Macintosh */
  61. // Alas, MPW C++ doesn't have an ANSI C conformant preprocessor, so
  62. //  the AT&T code as given doesn't work. The code below will work for 
  63. //  MPW C++, but **NOT** for a compiler with an ANSI C conformant
  64. //  preprocessor because the preprocessor isn't supposed to expand 
  65. //  operands of ##. Undefine applec to use this header with other
  66. //  compilers. Thanks to Allen Cecil for the suggested "fix". 
  67. # define declare(a,t)        a##declare(t)
  68. # define implement(a,t)      a##implement(t)
  69. # define declare2(a,t1,t2)   a##declare2(t1,t2)
  70. # define implement2(a,t1,t2) a##implement2(t1,t2)
  71. #else /* applec */
  72. #define declare(a,t) name2(a,declare)(t)
  73. #define implement(a,t) name2(a,implement)(t)
  74. #define declare2(a,t1,t2) name2(a,declare2)(t1,t2)
  75. #define implement2(a,t1,t2) name2(a,implement2)(t1,t2)
  76. #endif /* applec */
  77.  
  78. extern genericerror(int,char*);
  79. typedef int (*GPT)(int,char*);
  80. #define set_handler(generic,type,x) name4(set_,type,generic,_handler)(x)
  81. #define errorhandler(generic,type) name3(type,generic,handler)
  82. #define callerror(generic,type,a,b) (*errorhandler(generic,type))(a,b)
  83. #endif
  84.